#include<iostream>
using namespace std;

void solve(){
	string p,s;
	cin>>p>>s;
	int j=0;
	for(int i=0;i<p.size();){
		int ei=i+1;
		while(ei<p.size()&&p[i]==p[ei])ei++;
		int ej=j+1;
		while(ej<s.size()&&s[j]==s[ej])ej++;
		if(j>=s.size()||p[i]!=s[j]||ej-j>(ei-i)*2||ej-j<ei-i){
			cout<<"NO"<<endl;
			return ;
		}
		i=ei;
		j=ej;
	}
	if(j!=s.size()){
		cout<<"NO"<<endl;
		return ;
	}
	cout<<"YES"<<endl;
}

int main(){
	int t;
	cin>>t;
	while(t--){
		solve(); 
	}
	return 0;
} 
